import store from '@/store'

// 文件类型过滤
export function fileType(type) {
  switch (parseInt(type)) {
    case 1: return '1'
    case 2: return '2'
    case 3: return '3'
    case 4: return '4'
    case 5: return '5'
    default: return '-'
  }
}

// 用户类型过滤
export function userTypeFilter(type, state = 'name') {
  if (!type) return '-'
  return store.getters.userType[type + ''][state]
}

// 安排类型过滤
export function planTypeFilter(type) {
  if (type === undefined) return '-'
  else {
    const types = store.getters.planType
    for (let i = 0; i < types.length; i++) {
      if (parseInt(type) === types[i].id) return types[i].name
    }
    return '-'
  }
}

// 性别过滤
export function sexsFilter(sex) {
  if (sex === undefined) return '-'
  else {
    const sexs = store.getters.sexs
    for (let i = 0; i < sexs.length; i++) {
      if (parseInt(sex) === sexs[i].value) return sexs[i].label
    }
    return '-'
  }
}

// 事项状态过滤
export function nodeStatusFilter(status) {
  if (status === undefined) return '-'
  else {
    const nodeStatus = store.getters.nodeStatus
    for (let i = 0; i < nodeStatus.length; i++) {
      if (parseInt(status) === nodeStatus[i].value) return nodeStatus[i].label
    }
    return '-'
  }
}

// 事项状态过滤
export function nodeStatusClassFilter(status) {
  if (status === undefined) return 'success'
  else {
    const nodeStatus = store.getters.nodeStatus
    for (let i = 0; i < nodeStatus.length; i++) {
      if (parseInt(status) === nodeStatus[i].value) return nodeStatus[i].type
    }
    return 'success'
  }
}

// 事项进度状态过滤
export function nodeProgressStatusFilter(status) {
  if (status === undefined) return '-'
  else {
    const nodeStatus = store.getters.nodeStatus
    for (let i = 0; i < nodeStatus.length; i++) {
      if (parseInt(status) === nodeStatus[i].value) return nodeStatus[i].label
    }
    return '-'
  }
}

// 事项进度状态过滤
export function nodeProgressStatusClassFilter(status) {
  if (status === undefined) return 'success'
  else {
    const nodeStatus = store.getters.nodeStatus
    for (let i = 0; i < nodeStatus.length; i++) {
      if (parseInt(status) === nodeStatus[i].value) return nodeStatus[i].type
    }
    return 'success'
  }
}

// 审核状态过滤
export function nodeAuditStatusFilter(status) {
  if (status === undefined) return '-'
  else {
    if (status === '0') return '未审核'
    if (status === '1') return '审核通过'
    if (status === '2') return '审核不通过'
  }
}

// 审核状态过滤
export function nodeAuditStatusClassFilter(status) {
  if (status === undefined) return 'success'
  else {
    if (status === '0') return 'info'
    if (status === '1') return 'success'
    if (status === '2') return 'danger'
  }
}

// 事项更新进度状态过滤
export function nodeProgressStatusListFilter(status) {
  if (status === undefined) return '-'
  else {
    const nodeStatus = store.getters.nodeProgressStatusList
    for (let i = 0; i < nodeStatus.length; i++) {
      if (parseInt(status) === nodeStatus[i].value) return nodeStatus[i].label
    }
    return '-'
  }
}

// 事项更新进度状态过滤
export function nodeProgressStatusListClassFilter(status) {
  if (status === undefined) return 'success'
  else {
    const nodeStatus = store.getters.nodeProgressStatusList
    for (let i = 0; i < nodeStatus.length; i++) {
      if (parseInt(status) === nodeStatus[i].value) return nodeStatus[i].type
    }
    return 'success'
  }
}

